<?php
/*******************************************************************************
 * 3 column dashboard
 * 3 column riverdashboard Index page
 *
 * @package 3 column dashboard
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Fusion <contact@donkeydesigns.us>
 * @copyright TheFloridaCircle.com 2008-2009
 * @link http://www.thefloridacircle.com/
 *
 ******************************************************************************/


		require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');

		gatekeeper();
		
		$content = get_input('content','');
		$content = explode(',',$content);
		$type = $content[0];
		$subtype = $content[1];
		$orient = get_input('display');
		$callback = get_input('callback');
		
		if ($type == 'all') {
			$type = '';
			$subtype = '';
		}

		$body = '';
		if (empty($callback)) {
					
			
			//set a view to display a welcome message
			$area4 .= elgg_view("riverdashboard/welcome");
			
			//set a view for the left column
			$area1 .= elgg_view("riverdashboard/miniprofile");
			//$area1 .= elgg_view("riverdashboard/pymk");
			
			if(get_plugin_setting("show_newestmembers", "riverdashboard") != "no") {
				$area1 .= elgg_view("riverdashboard/newestmembers");}
			
			if(get_plugin_setting("show_featured_groups", "riverdashboard") != "no") {
            	$area1 .= elgg_view("riverdashboard/featured_groups");}
            	
            if(get_plugin_setting("show_mygroups", "riverdashboard") != "no") {
            	$area1 .= elgg_view("riverdashboard/mygroups");}

            if(get_plugin_setting("show_sidebartagcloud", "riverdashboard") != "no"){
				$area1 .= elgg_view("riverdashboard/sidebarTagcloud");}
			
			//set a view for the wire
			$body .= elgg_view("riverdashboard/activity_view");

			//set a view for the right column
			$area3 .= elgg_view("riverdashboard/sitemessage");
			
			if(get_plugin_setting("show_friends", "riverdashboard") != "no"){
				$area3 .= elgg_view("riverdashboard/friends");}
				
			//$area3 .= elgg_view("riverdashboard/birthdaymembers");
			if(get_plugin_setting("show_polls", "riverdashboard") != "no"){
				$area3 .= elgg_view("riverdashboard/poll");}

			if(get_plugin_setting("show_photocumulus", "riverdashboard") != "no"){
				$area3 .= elgg_view("riverdashboard/photo_cumulus");}
			
			if(get_plugin_setting("show_videos", "riverdashboard") != "no"){
				$area3 .= elgg_view("riverdashboard/video");}
				
			if(get_plugin_setting("show_recentview", "riverdashboard") != "no"){
				$area3 .= elgg_view("riverdashboard/recentview");}
			
		}
		
		switch($orient) {
			case 'mine':
							$subject_guid = $_SESSION['user']->guid;
							$relationship_type = ''; 
							break;
			case 'friends':	$subject_guid = $_SESSION['user']->guid;
							$relationship_type = 'friend';
							break;
			default:		$subject_guid = 0;
							$relationship_type = '';
							break;
		}

		$river = elgg_view_river_items($subject_guid, 0, $relationship_type, $type, $subtype, '') . "</div>";
		// Replacing callback calls in the nav with something meaningless
		$river = str_replace('callback=true','replaced=88,334',$river);
		
		$nav = elgg_view('riverdashboard/nav',array(
															'type' => $type,
															'subtype' => $subtype,
															'orient' => $orient 
														));
		if (empty($callback)) {
			$body .= elgg_view('riverdashboard/container', array('body' => $nav . $river . elgg_view('riverdashboard/js')));
			page_draw(elgg_echo('dashboard'),elgg_view_layout('three_column2',$area1,$body,$area3,$area4));
		} else {
			header("Content-type: text/html; charset=UTF-8");
			echo $nav . $river . elgg_view('riverdashboard/js');
		}

?>
